package com.onLineCar.manages.web;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.onLineCar.common.core.domain.Result;
import com.onLineCar.manages.pojo.China;
import com.onLineCar.manages.service.BaseService;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhucaiyi
 * @since 2023-12-10
 */
@RestController
@RequestMapping("/base")
public class BaseController {

    @Resource
    private BaseService chinaService;

    /**
     * 城市元素树
     * @return
     */
    @GetMapping("/cityElementTree")
    public Result<List<China>> cityTree(){
        return Result.success(chinaService.cityTree());
    }

    /**
     * 城市列表
     * @return
     */
    @GetMapping("/cityElementList")
    public Result<List<China>> list(){
        LambdaQueryWrapper<China> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(China::getPid, NumberUtils.INTEGER_ZERO);
        return Result.success(chinaService.list(lambdaQueryWrapper));
    }

}

